﻿CREATE TABLE [CO].[DefekturaCategories] (
    [Id]                  INT           NOT NULL,
    [Name]                VARCHAR (50)  NOT NULL,
    [MinPeekValForPeriod] REAL          NULL,
    [MaxPeekValForPeriod] REAL          NULL,
    [PrblCode]            REAL          NULL,
    [Note]                VARCHAR (250) NULL,
    [MD]                  DATETIME      DEFAULT (getdate()) NOT NULL,
    [MW]                  VARCHAR (50)  DEFAULT (suser_sname()) NOT NULL,
    [ToDelete]            BIT           DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_DefekturaCategories] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_DefekturaCategories_DefekturaProbabilyties] FOREIGN KEY ([PrblCode]) REFERENCES [CO].[DefekturaProbabilyties] ([Code]) NOT FOR REPLICATION
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Граничная доля всплеска (%) - минимальная доля всплеков в общем объёме продаж за период', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'DefekturaCategories', @level2type = N'COLUMN', @level2name = N'MinPeekValForPeriod';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Пороговая  доля всплесков (%) - максимальная доля всплеков в общем объёме продаж за период', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'DefekturaCategories', @level2type = N'COLUMN', @level2name = N'MaxPeekValForPeriod';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Код вероятности отказа покупателем', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'DefekturaCategories', @level2type = N'COLUMN', @level2name = N'PrblCode';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Признак того, что запись нужно удалить из БД всех подразделений', @level0type = N'SCHEMA', @level0name = N'CO', @level1type = N'TABLE', @level1name = N'DefekturaCategories', @level2type = N'COLUMN', @level2name = N'ToDelete';

